/*

This file is part of Rooms3D.

Copyright (C) 2008 Pixecur Technologies Incorporated (Esotera).
Visit Esotera at http://www.esoteras3.com
 
Rooms3D is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
 
Rooms3D is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with Rooms3D; see the file COPYING.  If not, write to 
Pixecur Technologies, 213-31 Peet Street, St. John's, NL, A1B 3W8. 
 
Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
 
*/

package com.datasentinel.rooms.file.sh3d;

import java.io.File;

import javax.vecmath.Vector3f;

import com.datasentinel.rooms.ui.sh3d.CustomFurnitureBuilder;
import com.datasentinel.rooms.ui.sh3d.CustomFurnitureSupport;
import com.eteks.sweethome3d.model.PieceOfFurniture;

public class FilePieceOfFurnitureBuilder implements CustomFurnitureBuilder
{
	private File file;
	private CustomFurnitureSupport customFurnitureSupport;
	public FilePieceOfFurnitureBuilder(File file,CustomFurnitureSupport customFurnitureSupport)
	{
		this.file = file;
		this.customFurnitureSupport = customFurnitureSupport;
	}
	public FilePieceOfFurnitureBuilder(File file)
	{
		this(file,new HaiVanPassPictureFrameFurnitureSupport());
	}
	@Override
	public PieceOfFurniture build()
	{
		Vector3f modelSize = customFurnitureSupport.getModelSize();
		float width = modelSize.x;
		float height = modelSize.y;
		float depth = modelSize.z;
		float elevation = 140;
		boolean movable = true;
		boolean doorOrWindow = false;
		Integer color = null;
		float[][] modelRotation = new float[][] { { 1, 0, 0 }, { 0, 1, 0 },
				{ 0, 0, 1 } };
		boolean backFaceShown = false;
		float iconYaw = (float)Math.PI / 8;
		boolean proportional = true;
		FilePieceOfFurniture newPiece = new FilePieceOfFurniture(file,
				null, customFurnitureSupport.getModelContent(), width,
				depth, height, elevation, movable, doorOrWindow, color,
				modelRotation, backFaceShown, iconYaw, proportional);
		return newPiece;
	}
}
